package market

import (
	"context"
	cards2 "git.900sui.cn/kc/rpcinterface/interface/cards"
	"git.900sui.cn/kc/rpcinterface/interface/common"
	"git.900sui.cn/kc/rpcinterface/interface/elastic/cards"
	"git.900sui.cn/kc/rpcinterface/interface/order"
)

const (
	//是否已删除
	IS_DEL_NO = 0 	//0否
	IS_DEL_YES = 1	//1是

	//体验 活动状态 1未开始  2进行中 3已结束
	EXPERIENCE_STATUS_NOT_START = 1
	EXPERIENCE_STATUS_STARTING = 2
	EXPERIENCE_STATUS_FINISH = 3

	//用户使用状态
	USER_EXPERIENCE_STATUS_NOT_USE = 1		//未使用
	USER_EXPERIENCE_STATUS_USED = 2			//已经用
	USER_EXPERIENCE_STATUS_OVERDUE = 3		//已过期

/*	//是否永久有效
	IS_PERPETUAL_NO = 0  // 否
	IS_PERPETUAL_YES = 1	//是*/
)


//查询一条体验-入参
type ArgsGetOneExperience struct {
	common.BsToken
	ExperienceId int
}

//查询一条体验 返回值
type ReplyGetOneExperience struct {
	Id int  //体验id
	BusId int   //总店id
	Name	string				//活动名称
	ActivityTimeStart	string	//活动开始时间
	ActivityTimeEnd	string		//活动结束时间
	ActivityShop	int   //活动门店
	//IsPerpetual	int	//是否永久有效 0否 1是
	PartNew	int	//是否仅限新用户参与 0否 1是
	PartCount	int	//老用户参与限制次数
	PartType	int	//参与方式 当前仅能线上参与 默认0
	ExperienceProductList []struct {
		Id int //体验-产品 id
		ExperienceId int //体验id
		SspId	int //单项目价格规格id
		SpecIds string //规格组合id
		SpecNames []string //规格组合名称
		SingleId	int //单项目id
		SingleName string //单项目名称
		OriginalPrice float64 //原价
		Stock int//库存数
		Price	float64 //体验价
	}
	ExperienceShopList []struct {
		Id	int		//体验-门店 id
		ExperienceId	int	//体验id
		ShopId	int		//门店id
		ShopName string //门店名称
		BranchName string //分店名称
		BusId	int		//总店id
		Num	int			//成交数量
	}
}

/*	ExperienceShop
	Id	int		//体验-门店 id
	ExperienceId	int	//体验id
	ShopId	int		//门店id
	BusId	int		//总店id
	Num	int			//成交数量
	Status	int		//体验状态：1未开始 2进行中 3已结束
	IsDel	int		//是否已经删除 0否 1是
	DelTime	string	//删除时间
*/

/*	ExperienceProduct
	Id int //体验-产品 id
	ExperienceId int //体验id
	SspId	int //单项目价格规格id
	SingleId	int //单项目id
	Stock	int //库存数量
	FrozenStock int //锁定库存
	Num int //成交数量
	Price	float64 //体验价
	IsDel	int	//是否已经删除 0否 1是
	DelTime	string		//删除时间
*/

/*	Experience
	Id int  //体验id
	BusId int   //总店id
	Name	string				//活动名称
	ActivityTimeStart	string	//活动开始时间
	ActivityTimeEnd	string		//活动结束时间
	ActivityShop	int   //活动门店
	Num	string	//成交数量
	IsPerpetual	int	//是否永久有效 0否 1是
	PartNew	int	//是否仅限新用户参与 0否 1是
	PartCount	int	//老用户参与限制次数
	PartType	int	//参与方式 当前仅能线上参与 默认0
	Status	int	//活动状态 1未开始 2进行中 3已结束
	IsDel	int	//是否已经删除 0否 1是
	CreateTime	string  //创建时间
	DelTime	string		//删除时间
*/

//总店新建体验入参
type ArgsExperience struct {
	common.BsToken
	Id  int  //活动id
	Name	string				//活动名称
	ActivityTimeStart	string	//活动开始时间
	ActivityTimeEnd	string		//活动结束时间
	//IsPerpetual	int	//是否永久有效 0否 1是
	PartNew	int	//是否仅限新用户参与 0否 1是
	PartCount	int	//老用户参与限制次数
	PartType	int	//参与方式 当前仅能线上参与 默认0
	Singles []struct {	//活动单项目信息
		ExperienceProductId int //体验产品id
		SspId	int //单项目价格规格id
		SingleId	int //单项目id
		Stock	int //库存数量
		Price	float64 //体验价
	}
	ShopIds []int    //门店id集合
}

//总店或者门店查询体验列表入参
type ArgsGetExperience struct {
	common.BsToken
	common.Paging
	Status int //活动状态 1未开始 2进行中 3已结束  0查询全部
	Name string //后缀模糊匹配
}

//总店或者门店查询体验列表返回值
type ReplyGetExperience struct {
	TotalNum int
	Lists []GetExperienceList
}

type GetExperienceList struct {
	Id  int  //活动id
	Name	string				//活动名称
	ActivityTimeStart	string	//活动开始时间
	ActivityTimeStartStr string //活动开始时间
	ActivityTimeEnd	string		//活动结束时间
	ActivityTimeEndStr	string		//活动结束时间
	//IsPerpetual	int	//是否永久有效 0否 1是
	PartNew	int	//是否仅限新用户参与 0否 1是
	PartCount	int	//老用户参与限制次数
	PartType	int	//参与方式 当前仅能线上参与 默认0
	ActivityShop	int   //活动门店
	Num	string	//成交数量
	Status	int	//活动状态 1未开始 2进行中 3已结束
}

type ArgsGetExperienceActivity struct {
	ShopIds []int
}

//查看一条体验详情-入参
type ArgsGetOneExperienceSingleDetail struct {
	ExperienceProductId int
	ShopId int
}

//查看一条体验详情-返回值
type ReplyGetExperienceDetail struct {
	/*ShopId int
	SsId int
	ShotDesc string
	SingleName string
	Price float64
	SpecIds string
	SpecNames string
	ServerTime int
	ImgId int
	ImgPath string
	SingleId int
	SingleContent []cards2.SingleContextInfo*/
	cards2.SingleDetail
	ExperienceId int
	ExperienceProductId int
	ExperiencePrice float64
	RemainingTimes int
	ActivityTimeStart string
	ActivityTimeEnd string
	//IsPerpetual int	//0 有期限   1永久有效
	PartNew int		//0否    1仅限新用户参与
	PartCount int		//老用户限制参与次数
	PartType int	//0 仅能通过线上参与
	SspId   int     // 组合规格ID
	SspName string  // 组合规格名
	SspPrice   float64 // 组合规格价格
}

//总店或者门店编辑体验状态 -入参
type ArgsEditExperienceStatus struct {
	common.BsToken
	ExperienceId int
	//Status int
}

//总店删除一条体验- 入参
type ArgsDelExperience struct {
	common.BsToken
	ExperienceId int
}

// 拼团活动-适用门店-入参
type ArgsGetExperienceApplyShop struct {
	Lng   float64
	Lat   float64
	ExperienceId int
}

//用户消费体验单-入参
type ArgsConsumerExperience struct {
	common.BsToken
	Lists []struct {
		UepId int
		Num int
	}
}

//查询用户体验单 - 入参
type ArgsGetUserExperience struct {
	common.Utoken
	common.Paging
	Status int
}

//查询用户体验单 - 返回值
type ReplyGetUserExperience struct {
	TotalNum int
	Lists    []ReplyGetUserExperienceLists
}

type ReplyGetUserExperienceLists struct {
	UepId             int
	ShopId            int
	ShopName          string
	BranchName        string
	ExperienceId      int
	ActivityTimeStart string
	ActivityTimeEnd   string
	//IsPerpetual       int
	SingleId          int
	SingleName        string
	SspId   		  int
	Num               int
	UseTime           string
	ShotDesc string
	SpecIds string
	SpecNames string
	ServerTime int
	ImgId int
	ImgPath string
}

//校验体验参数 - 入参
type ArgsCheckExperience struct {
	BusId int
	ShopId int
	Uid int
	Num int
	ExperienceProductId int
}

//校验体验参数 - 返回值
type ReplyCheckExperience struct {
	Price float64
	ExperienceId int
	MemberId int
}

//冻结释放库存-rpc - 入参
type ArgsFrozenStock struct {
	Status int //1冻结 2释放
	ExperienceProductId int
	Num int
}

//获取用户体验单项目信息-rpc -入参
type ArgsGetUserExperienceInfo struct{
	BusId int
	UserId int
	SingleId int
	SspId int
}


//app根据门店id获取所有体验 - 入参
type ArgsGetShopExperienceInfo struct {
	ShopId int
	common.Paging
}

//app根据门店id获取所有体验 - 返回值
type ReplyGetShopExperienceInfo struct {
	TotalNum int
	Lists []ShopExperience
}

type ShopExperience struct {
	ExperienceId int
	ExperienceName string
	TimeRemaining int64
	ExperienceProductLists []ShopExperienceProduct
}

type ShopExperienceProduct struct {
	ExperienceProductId int
	SingleId int
	Ssid int
	SingleName string
	ImgId int
	SingleImgUrl string
	SspId int
	SpecIds string
	SpecName string
	ExperiencePrice float64
	Price float64
	Remaining int //剩余数量
	ShotDesc string
	ServerTime int
}

//用户消费体验校验-rpc -入参
type ArgsConsumerCheckout struct {
	ShopId int
	UserId int
	SingleLists []struct {
		UepId int
		SingleId int
		SspId int
		Num int
	}
}

type Experience interface {
	//总店新建体验
	AddExperience(context.Context, *ArgsExperience, *bool) error
	//总店编辑体验
	EditExperience(context.Context, *ArgsExperience, *bool) error
	//查询一条体验
	GetOneExperience(ctx context.Context, args *ArgsGetOneExperience, reply *ReplyGetOneExperience) error
	//总店或者门店查询体验列表
	GetExperience(context.Context, *ArgsGetExperience, *ReplyGetExperience) error
	//过滤没有活动的门店
	FilterShopsHaveActivity(ctx context.Context, args *cards.ArgsSetShopsActivity, reply *[]int) error
	//获取体验列表-rpc
	GetExperienceActivity(ctx context.Context, args *ArgsGetExperienceActivity, reply *map[int][]cards2.ExperienceList) error
	//查看一条体验详情
	GetExperienceDetail(ctx context.Context, args *ArgsGetOneExperienceSingleDetail, reply *ReplyGetExperienceDetail) error
	//总店结束体验状态
	OverExperience(ctx context.Context, args *ArgsEditExperienceStatus, reply *bool) error
	//总店删除一条体验
	DelExperience(ctx context.Context, args *ArgsEditExperienceStatus, reply *bool) error
	//查询体验适用门店
	GetExperienceApplyShop(ctx context.Context, args *ArgsGetExperienceApplyShop, reply *[]order.ReplyCableShopInfo) error
	//校验体验参数
	CheckExperience(ctx context.Context, args *ArgsCheckExperience, reply *ReplyCheckExperience) error
	//创建用户体验单
	AddUserExperience(ctx context.Context, args int, reply *int) error
	//用户消费体验单
	ConsumerExperience(ctx context.Context, args *ArgsConsumerExperience, reply *bool) error
	//查询用户体验单
	GetUserExperience(ctx context.Context, args *ArgsGetUserExperience, reply *ReplyGetUserExperience) error
	//定时任务 - 每天0点更新
	AutoUpdateStatus(ctx context.Context, args *bool, reply *bool) error
	//冻结释放库存-rpc
	FrozenStock(ctx context.Context, args *ArgsFrozenStock, reply *bool) error
	//获取用户体验单项目信息
	GetUserExperienceInfo(ctx context.Context, args *ArgsGetUserExperienceInfo, reply *[]order.ExperienceList) error
	//app根据门店id获取所有体验
	GetShopExperienceInfo(ctx context.Context, args *ArgsGetShopExperienceInfo, reply *ReplyGetShopExperienceInfo) error
	//用户消费体验校验
	ConsumerCheckout(ctx context.Context, args *ArgsConsumerCheckout, reply *bool) error
	//删除单项目时检查体验是否占用
	DelExperienceCheck(ctx context.Context, args *[]int, reply *bool) error
}
